from pyramid.configuration import Configurator
from ampersands.omero.models import get_root
import pyramid_zcml

def app(global_config, **settings):
    """ This function returns a WSGI application.

    It is usually called by the PasteDeploy framework during
    ``paster serve``.
    """
    zcml_file = settings.get('configure_zcml', 'configure.zcml')
    config = Configurator(root_factory=get_root, settings=settings)
    config.begin()
    config.include(pyramid_zcml)
    config.load_zcml(zcml_file)
    config.end()
    return config.make_wsgi_app()
